load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//pkg/testutils:buildutil/buildutil.bzl", "disallowed_imports_test")

go_library(
    name = "catalog",
    srcs = [
        "catalog.go",
        "descriptor.go",
        "descriptor_id_set.go",
        "errors.go",
        "metadata.go",
        "post_deserialization_changes.go",
        "schema.go",
        "system_table.go",
        "table_col_map.go",
        "table_col_set.go",
        "table_elements.go",
        "validate.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/catalog",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/clusterversion",
        "//pkg/config/zonepb",
        "//pkg/geo/geopb",
        "//pkg/jobs/jobspb",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/roachpb",
        "//pkg/security/username",
        "//pkg/server/telemetry",
        "//pkg/sql/catalog/catenumpb",
        "//pkg/sql/catalog/catpb",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/fetchpb",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/privilege",
        "//pkg/sql/schemachanger/scpb",
        "//pkg/sql/sem/catconstants",
        "//pkg/sql/sem/semenumpb",
        "//pkg/sql/sem/tree",
        "//pkg/sql/types",
        "//pkg/util",
        "//pkg/util/hlc",
        "//pkg/util/intsets",
        "//pkg/util/iterutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_cockroachdb_redact//interfaces",
    ],
)

go_test(
    name = "catalog_test",
    size = "small",
    srcs = [
        "descriptor_test.go",
        "table_col_map_test.go",
        "table_col_set_test.go",
    ],
    embed = [":catalog"],
    deps = [
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/dbdesc",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/schemadesc",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/util",
        "//pkg/util/intsets",
        "//pkg/util/randutil",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_stretchr_testify//require",
        "@in_gopkg_yaml_v2//:yaml_v2",
    ],
)

disallowed_imports_test(
    "catalog",
    disallow_cdeps = True,
    disallowed_list = [
        "//pkg/sql/sem/eval",
    ],
)
